package com.hsy.springmvc.controller;


import com.hsy.springmvc.common.Json;
import com.hsy.springmvc.model.User;
import com.hsy.springmvc.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by hsy on 2017/12/29.
 */
@RestController
public class UserController {

    @Autowired
    private IUserService userService;

    @RequestMapping("/user")
    public String user() {
        User user = new User();
        user.setAge("20");
        user.setName("hello222");
        userService.saveBean(user);

        return "userlist";
    }

    @RequestMapping("/getUser")
    public Json getUser() {
        User user = userService.get(1l);
        Json json = new Json();
        json.setSuccess(true);
        json.setMsg("获取用户信息成功");
        json.setObj(user);
        return json;
    }
}
